/**
 * Copyright (C) 2011 KingCore Science & Technology CO,.LTD. All rights reserved.
 * XNS PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

/**
 * Copyright (C) 2002-2011 WUZEWEN. All rights reserved.
 * WUZEWEN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 *
 * This software is the confidential and proprietary information of
 * WuZeven, Personal. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with WuZeven.
 */

package com.kingcore.director.calendar.ui;

import java.awt.Color;
import java.awt.Event;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Observable;
import java.util.Observer;
import java.util.ResourceBundle;
import java.util.Vector;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JRadioButton;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.border.EmptyBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.border.LineBorder;
import javax.swing.event.ChangeListener;
import javax.swing.table.DefaultTableModel;

import org.apache.log4j.Logger;

import wzw.swing.table.PlainTable;
import wzw.util.ComponentUtil;
import wzw.util.I18nUtil;
import wzw.util.I18nUtils;

import com.kingcore.director.DirectorConstants;
import com.kingcore.director.calendar.dao.CalendarDao;
import com.kingcore.director.calendar.dao.impl.CalendarDaoImpl;
import com.kingcore.director.core.util.DirectorStringUtils;
import com.kingcore.director.core.util.Lunar;
import com.kingcore.director.main.MainFrame;
import com.kingcore.director.reminder.bean.AwokeBean;

/**
 * <p>java class file describe</p>
 * @author Zeven on 2011-3-1
 * @version	1.0
 * @see		Object#equals(java.lang.Object)
 * @since	JDK5
 */

public class CalendarSelectorPanel  extends JPanel implements ActionListener, Observer{

    //log object
   	private final static Logger log = Logger.getLogger(CalendarMainPanel.class);


    public static String[] weeks={"星期日","星期一","星期二","星期三",
                                  "星期四","星期五","星期六"};
    
    public static String constellation(Calendar cal){
  
                String [][]con ={
                     {"水瓶座","0122","0221"},
                     {"双鱼座","0222","0321"},
                     {"白羊座","0322","0420"},
                     {"金牛座","0421","0521"},
                     {"双子座","0522","0621"},
                     {"巨蟹座","0621","0721"},
                     {"狮子座","0722","0821"},
                     {"处女座","0822","0921"}, 
                     {"天秤座","0922","1021"},
                     {"天蝎座","1022","1121"},
                     {"射手座","1122","1221"},
                     {"摩羯座","1222","0121"}};
                int month=cal.get(Calendar.MONTH)+1;
                int today=cal.get(Calendar.DAY_OF_MONTH);
                String month_str=month<10?"0"+month:""+month;
                String today_str=today<10?"0"+today:""+today;
                String str=month_str+today_str;
                for( int i = 0 ; i < con.length-1 ; i++ )
                {
                     if(Integer.parseInt(str) >= Integer.parseInt(con[i][1]) && Integer.parseInt(str) <= Integer.parseInt(con[i][2]))
                        return con[i][0]; 
                 
                }
                if((Integer.parseInt(str) >= Integer.parseInt(con[11][1]) && Integer.parseInt(str) < 1232) ||  Integer.parseInt(str) <=Integer.parseInt( con[11][2]) )
                   return  con[11][0];
       
               return "error!";
        }
       
        
    /**
	 * 
     */
	private static final long serialVersionUID = 1L;
	public static void main(String[] args) {
		System.out.println(DirectorStringUtils.getBeforeAfterDate("2011-02-26", 1));
		System.out.println(DirectorStringUtils.getBeforeAfterDate("2011-02-26", 3));
		System.out.println(DirectorStringUtils.getBeforeAfterDate("2011-02-26", -26));
//     SwingConsole.run(new Simple_Calendar(),525,525);
    }

	HashMap<String,String>  sFestivalMap = null;
	HashMap<String,String>  wFestivalMap = null;
	HashMap<String,String>  lFestivalMap = null;

	private MainFrame mainFrame = null;
    private PlainTable tableList = null;
    public CalendarSelectorPanel(MainFrame mainFrame, PlainTable plainTable ){

    	this.mainFrame = mainFrame;
    	this.tableList = plainTable;
    	/* 节日和纪念日
    	   格式：起始年(yyyy)+月(mm)+日(dd) 

    	   0000表示起始年不明*/
    	sFestivalMap =new  HashMap<String,String>();
    	//String []sFestival_={
    	sFestivalMap.put("0101","  元旦");
    	sFestivalMap.put("0214","情人节");
    	sFestivalMap.put("0308","妇女节");
    	sFestivalMap.put("0312","植树节");
    	sFestivalMap.put("0401","愚人节");
    	sFestivalMap.put("0501","劳动节");
    	sFestivalMap.put("0504","青年节");
    	sFestivalMap.put("0601","儿童节");
    	sFestivalMap.put("0701","建党节");
    	sFestivalMap.put("0801","建军节");
    	sFestivalMap.put("0910","教师节");
    	sFestivalMap.put("1001","国庆节");
    	sFestivalMap.put("1031","万圣节");
    	sFestivalMap.put("1112","孙中山诞辰");
    	sFestivalMap.put("1225","圣诞节");
    	sFestivalMap.put("1226","毛泽东诞辰");
    	//};
    	//某月第几个星期几
    	//起始年(4位)+月(2位)+第几个(1位)+星期几(1位)
    	wFestivalMap =new  HashMap<String,String>();
    	//String []wFestival={
    	wFestivalMap.put("0520","母亲节");
    	wFestivalMap.put("0630","父亲节");
    	wFestivalMap.put("1144","感恩节");
    	//};
    	//农历 99表示月最后一天
    	lFestivalMap =new  HashMap<String,String>();
    	//String []lFestival={
    	lFestivalMap.put("0101","春 节");
    	lFestivalMap.put("0102","大年初二");
    	lFestivalMap.put("0103","大年初三");
    	lFestivalMap.put("0115","元宵节");
    	lFestivalMap.put("0202","春龙节");
    	lFestivalMap.put("0505","端午节");
    	lFestivalMap.put("0513","泼水节");
    	lFestivalMap.put("0707","七 夕");
    	lFestivalMap.put("0815","中秋节");
    	lFestivalMap.put("0909","重阳节");
    	lFestivalMap.put("1208","腊八节");
    	lFestivalMap.put("1299","除 夕");
    	//};
    	   
//     setTitle(" 阴历及节日软件 2008 beta1");
//     setIconImage(this.getToolkit().createImage("title.gif"));
//     setResizable(false);
    	calendar = Calendar.getInstance();
    	today = calendar.get(Calendar.DAY_OF_MONTH);
    	panel_Header=initializtion_Header();
    	//panel_Header.setVisible(false);

    	panel_Week =initializtion_Week();
    	//panel_Header.setVisible(false);

    	panel_Calendar=initializtion_Calendar();
    	setLayout(null);
    	setBounds(185,125,0,0);
    	add(panel_Header);   panel_Calendar.setBounds(0 ,0  ,525 , 45);
    	add(panel_Week);     panel_Week.setBounds(0 ,45 ,525 , 35);
    	add(panel_Calendar);panel_Calendar.setBounds(0 ,80 ,525 , 415) ;
    	initializtion_Data(calendar);

    	this.update(null, null);
    }
    
	private  JPanel initializtion_Header(){//显示表头的panel
         
        JPanel panel = new JPanel();
        year_box  = new  JComboBox();
        month_box = new JComboBox();
        cross=new JRadioButton("c",false);cross.addActionListener(new LookAndFeel_Listener());
        system=new JRadioButton("s",false);system.addActionListener(new LookAndFeel_Listener());
        motif=new JRadioButton("m",false);motif.addActionListener(new LookAndFeel_Listener());
        feel_group= new ButtonGroup();
        show_help = new JButton("说 明");
        
        show_help.addActionListener(new Statement_Listener());
        
        feel_group.add(cross);feel_group.add(system);feel_group.add(motif);
        
        panel.setBorder(new EtchedBorder(5,Color.red,Color.BLUE));
        JLabel year_l = new JLabel("请您选择年份: ",JLabel.RIGHT);
        JLabel month_l = new JLabel("月份: ",JLabel.RIGHT);
        panel.setLayout(null);
        panel.setSize(525,45); 

        for(int i = 1900 ;i < 2050 ; i++)
           year_box.addItem(""+i);
        for(int j = 1 ; j <= 12 ;j++)
           month_box.addItem(""+j) ;
      
        year_box.setSelectedIndex(calendar.get(Calendar.YEAR)-1900);
        month_box.setSelectedIndex(calendar.get(Calendar.MONTH));
        panel.add(year_l);      year_l.setBounds(0,10,95,25);
        panel.add(year_box);  year_box.setBounds(100,10,65,25);
        panel.add(month_l);    month_l.setBounds(160,10,45,25);
        panel.add(month_box);month_box.setBounds(210,10,45,25);
//        JLabel look_feel = new JLabel("外观:",JLabel.RIGHT);
//        panel.add(look_feel);look_feel.setBounds(290-38,10,38,25);
//        panel.add(cross);       cross.setBounds(290,10,38,25);
//        panel.add(system);     system.setBounds(325,10,32,25);
//        panel.add(motif);       motif.setBounds(355,10,38,25);
//        panel.add(show_help);  show_help.setBounds(400,10,65,25);
        show_help.setBorder(new EmptyBorder(0,0,0,0));
        show_help.setBackground(Color.getHSBColor(23,21,10));
        year_box.addActionListener(this);
        month_box.addActionListener(this);
        return panel;
       }

	private JPanel initializtion_Week(){//显示星期的panel
		JPanel panel = new JPanel();
		panel.setLayout(new GridLayout(1,7));
		String columnNames[]={"星期日","星期一","星期二","星期三",
                                     "星期四","星期五","星期六"};
           JLabel label =null;
           for(int i=0;i<7;i++){
            label = new JLabel(columnNames[i],JLabel.CENTER);
            if(i == 0 || i == 6)
              label.setForeground(Color.RED);
            label.setBorder(new LineBorder(Color.BLUE));
            panel.add(label);
           }
           return panel;
	}
	
	private JPanel initializtion_Calendar(){//显示日期的panel
           JPanel panel = new JPanel();
        
           panel.setLayout(new GridLayout(6,7));
           for( int i = 0 ; i < 6 ; i++ ){
             for(int j = 0 ; j < 7 ; j++ ){
            label=new JLabel("",JLabel.CENTER);
            
            datas[i][j] = label;
            label.setBorder(new LineBorder(Color.BLUE));
            if(j==0 || j==6)
               label.setForeground(Color.RED); 
            datas[i][j].addMouseListener(new List_MouseListener());
            panel.add(label);
           }
        }
        return panel;
       }
      
       public  void clear_Data(){//清空内容的
        for(int i = 0 ; i < 6 ; i++ )
         for(int j = 0 ; j < 7 ; j++ ){
          datas[i][j].setText("");
          if(j==0 || j==6)
             datas[i][j].setForeground(Color.RED);
          else
             datas[i][j].setForeground(null);
         }
            
       }

       
       public  void initializtion_Data(Calendar calendar){//初始化函数
    	   ////////////////////////////////////////////////////
    	   this.calendar = calendar;
    	   today = calendar.get(Calendar.DAY_OF_MONTH);
    	   int month = calendar.get(Calendar.MONTH);
    	   int weekindexDay;
    	   int weekindexMonth;

    	   String year = calendar.get(Calendar.YEAR)+"";
    	   //wzw ------------------- 根据公历计算农历  begin
    	   //春分日期的计算[Y*D+C]-L
    	   //公式解读：年数的后2位乘0.2422加20.646取整数减闰年数。21世纪春分的C值=20.646。
    	   //举例说明：2092年春分日期=[92×.0.2422+20.646]-[92/4]=42-23=19，3月19日是春分。
    	   //例外：2084年的计算结果加1日
    	   Integer simpleYearNum = Integer.parseInt( year.substring(year.length()-2));
    	   int cfDay = (int) Math.floor(simpleYearNum*0.2422d + 20.646)
    	   - (int) Math.floor(simpleYearNum/4);
    	   String cfDayStr = cfDay>10?""+cfDay:"0"+cfDay;
    	   String cfMonDayStr = "03"+cfDayStr;
    	   sFestivalMap.put(cfMonDayStr,"春分");

    	   String qmjDateStr = DirectorStringUtils.getBeforeAfterDate(year+"-03-"+cfDayStr, 15);
    	   qmjDateStr = qmjDateStr.substring( qmjDateStr.indexOf("-")+1).replace("-", "");
    	   sFestivalMap.put(qmjDateStr,"清明节"); //清明节不固定，大约为每年阳历的4月4日至6日之间 。现在的清明是春分后十五天，而春分是新历3月21日前后
    	   log.info("动态计算农历节日-> 春分:"+cfMonDayStr + " 清明节:"+qmjDateStr);
    	   //wzw ------------------- 根据公历计算农历  end

    	   calendar.set(Calendar.DATE,1);
    	   while(calendar.get(Calendar.MONTH)==month){
				weekindexMonth = calendar.get(Calendar.WEEK_OF_MONTH) - 1;
				weekindexDay = calendar.get(Calendar.DAY_OF_WEEK) - 1;
				int day = calendar.get(Calendar.DAY_OF_MONTH);
				// /////////////////////////////////////////////
				String today_, month_;
				today_ = day < 10 ? "0" + day : "" + day;
				month_ = month < 10 ? "0" + (month + 1) : "" + (month + 1);
				Lunar lunar = new Lunar(calendar);
				String lunar_ = lunar.toString();
				// /////////////////////////////////////////
				if (null != sFestivalMap.get(month_ + today_))
					lunar_ = "<font color=red>" + sFestivalMap.get(month_ + today_);
				// /////
				String wFestival_ = month_ + (weekindexMonth) + (weekindexDay);
				
				if (null != wFestivalMap.get(wFestival_)) {
					lunar_ = "<font color=red>" + wFestivalMap.get(wFestival_);
					//System.out.println(wFestival_);
				}
				
				if (null != lFestivalMap.get(lunar.numeric_md()))
					lunar_ = "<font color=red>"
							+ lFestivalMap.get(lunar.numeric_md());
				
				// 计算除夕
				Calendar temp_calendar = Calendar.getInstance();
				temp_calendar.set(calendar.get(Calendar.YEAR), month, day + 1);
				
				// temp_calendar.add(Calendar.DAY_OF_MONTH,1);
				Lunar temp_lunar = new Lunar(temp_calendar);
				String temp_str = temp_lunar.numeric_md();
				if (temp_str.equals("0101"))
					lunar_ = "<font color=red>" + lFestivalMap.get("1299");
				// /计算除夕结束
				// ////////////////////////////////////////
				String day_str;
				if (day < 10)
					day_str = "<html><center><font size=6>" + today_;
				else
					day_str = "<html><center><font size=6>" + today_;
				
				day_str += "</font><br>" + lunar_;
				
				if (day == today)
					datas[weekindexMonth][weekindexDay].setForeground(Color.GREEN);
				datas[weekindexMonth][weekindexDay].setText(day_str);
				calendar.add(Calendar.DATE, 1);
    	   } 
        
    	   /////////////////////////////////////////////////    
       }
       
       public  void actionPerformed(ActionEvent e){//日期和年份的选择更新
    	   Object obj = e.getSource();
    	   if (obj==jpmi_MainTable_CreateNewReminder) {
    		   DateFormat df =  new java.text.SimpleDateFormat("HH:mm"); //yyyy-MM-dd HH:mm:ss
    		   String timeStr = df.format( Calendar.getInstance().getTime() ) + ":00";
    		   this.mainFrame.getReminderMainPanel().executeAddNewAwoke(null,null,selectedDateStr+" "+timeStr);
    		   
			}else if (obj==jpmi_MainTable_ViewAllReminders) {
				this.mainFrame.getMainTabbedPane().setSelectedIndex(MainFrame.MainTabPane_ReminderMainPanel_Index);
				
			}else{
		        int year = Integer.parseInt(year_box.getSelectedItem().toString()) ;
		        int month= Integer.parseInt(month_box.getSelectedItem().toString())-1 ;
		        calendar.set(year,month,today);
		        clear_Data();
		           initializtion_Data(calendar);
			}
       }
       
  class LookAndFeel_Listener implements ActionListener{//选择外观的样式
    public void actionPerformed(ActionEvent ev){
     JRadioButton o = (JRadioButton)ev.getSource();
     String str=o.getText();
     if("c" == str){
      try {UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
               } catch(Exception e) { e.printStackTrace(); }
     }else if("s" == str){
      try{UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                } catch(Exception e) {e.printStackTrace();}
     }else if("m" == str){
      try{UIManager.setLookAndFeel( ComponentUtil.getNimbusLookAndFeelClassName() );}
               catch(Exception e) {e.printStackTrace(); }
     }
     SwingUtilities.updateComponentTreeUI(CalendarSelectorPanel.this);
      }
    
       }
       class Statement_Listener implements ActionListener{//显示声明信息
        JDialog dialog=null;
        public void actionPerformed(ActionEvent ev){
//           String statment = "<html>阴历及节日程序 2008 beta1";
//            statment +="<br>免费软件(Free Software) 你可以无限传播与反编译.";
//            statment +="<br>该日历有三种外观样式,有从1900年至2049年间的所有阴历.";
//            statment +="<br>个人爱好开发  作者:朱春 Email:npuxbd@163.com";
//            statment +="<br>Copyright @ 2008- All Rights Reserved";
//           dialog=new  JDialog(Simple_Calendar.this, "阴历及节日软件 2008 beta1",true);
//                 dialog.setLayout(null);
//                 dialog.setBounds(285,215,365,185);
//                 JLabel label_s = new JLabel(statment);//label_s.setBackground(Color.RED);
//                 JButton button=new JButton("确 定");
//                 button.addActionListener(new ActionListener(){
//                  public void actionPerformed(ActionEvent evet){
//                     dialog.setVisible(false);
//                  }
//                 });
//                 dialog.add(label_s);label_s.setBounds(20,0,365,100);
//                 dialog.add(button);  button.setBounds(145,110,65,25);
//                 dialog.setVisible(true);
          }
        
       }
       JLabel lastSelectedLabel = null;
       class List_MouseListener implements MouseListener{//鼠标移入时显示的信息
        JLabel labe=null;
       // JLabel lastSelectedLabel = null;
        
        public void mouseClicked(MouseEvent e) {// 鼠标按键在组件上单击（按下并释放）时调用。
			labe = (JLabel) e.getSource();
			String labTxt = labe.getText();
			if (labTxt != "") {
				// change backgroud color
				if (lastSelectedLabel != null) {
					lastSelectedLabel.setBackground(null);
					lastSelectedLabel.setOpaque(true);
				}
				labe.setBackground(Color.BLUE);
				labe.setOpaque(true);
				lastSelectedLabel = labe;
				
				//fetch data
				String day = labTxt.substring(labTxt.indexOf("size=6>") + 7, labTxt
						.indexOf("</font>"));
				// String lun=lab.substring(lab.indexOf("<br>")+4);
				String dateStr = year_box.getSelectedItem().toString() + "-"
								+ (month_box.getSelectedItem().toString().length()==1?"0":"")
								+ month_box.getSelectedItem() + "-"
								+ day ;
				fetchData(dateStr);
			}
        	
		}

		public void mouseEntered(MouseEvent e) { // 鼠标进入到组件上时调用
			labe = (JLabel) e.getSource();
			String lab = labe.getText();
			if (lab != "") {
				String day = lab.substring(lab.indexOf("size=6>") + 7, lab
						.indexOf("</font>"));
				// String lun=lab.substring(lab.indexOf("<br>")+4);
				String message = "<html><body><center>公元 "
						+ year_box.getSelectedItem() + "年"
						+ month_box.getSelectedItem() + "月"
						+ Integer.parseInt(day) + "日";
				calendar.set(Integer.parseInt(year_box.getSelectedItem()
						.toString()), Integer.parseInt(month_box
						.getSelectedItem().toString()) - 1, Integer
						.parseInt(day));
				Lunar lunar = new Lunar(calendar);
				message += "<br><font color=red>"
						+ weeks[(calendar.get(calendar.DAY_OF_WEEK) - 1)];
				message += "&nbsp;&nbsp;&nbsp;&nbsp;" + constellation(calendar)
						+ "</font><br>农历 ";
				message += lunar.get_month() + "月" + lunar.get_Big_Or_Small()
						+ "&nbsp;&nbsp;&nbsp;&nbsp;" + lunar.get_date();// + "日";
				// message+=lunar.get_JQ();
				labe.setToolTipText(message);
				labe.setOpaque(true);
				// System.out.println(day+":"+lun);
			}

		}

		public void mouseExited(MouseEvent e) {// 鼠标离开组件时调用。

			// labe.setBackground(null); //using lastSelectedLabel
			// labe.setOpaque(true);
		}

		public void mousePressed(MouseEvent e) {// 鼠标按键在组件上按下时调用。
			Object obj = e.getSource();
			if (obj instanceof JLabel) {
				JLabel labe = (JLabel) e.getSource();
				String lab = labe.getText();
				if (lab==null || lab.trim().length()<1) {
					return ;
				}
				String day = lab.substring(lab.indexOf("size=6>") + 7, lab
						.indexOf("</font>"));
				// String lun=lab.substring(lab.indexOf("<br>")+4);
				String year = year_box.getSelectedItem().toString();
				String month = month_box.getSelectedItem().toString();
				// System.out.println(year+"-"+month+"-"+day);
				selectedDateStr = year + "-" 
									+ (month.length()==1?"0":"") + month + "-" 
									+ (day.length()==1?"0":"") + day;
				if (e.getButton() == MouseEvent.BUTTON3) { // 显示弹出菜单
					getPopupMenuForTable().setSelected(null);
					getPopupMenuForTable().show(e.getComponent(), e.getX(),
							e.getY());

				}
			}

		}

		public void mouseReleased(MouseEvent e) {// 鼠标按钮在组件上释放时调用。
		}

	}
       private String selectedDateStr = null;
       private JPopupMenu popupMenuForTable = null;
       private JMenuItem jpmi_MainTable_CreateNewReminder = null;
       private JMenuItem jpmi_MainTable_ViewAllReminders = null;
   	/**
	 * Table的弹出式菜单
	 */
   	private JPopupMenu getPopupMenuForTable(){ 
   		if(popupMenuForTable == null){
   			popupMenuForTable = new JPopupMenu();
   			
   			jpmi_MainTable_CreateNewReminder = new JMenuItem();
   			jpmi_MainTable_CreateNewReminder.setText("Create New Reminder");
   			jpmi_MainTable_CreateNewReminder.addActionListener( this );
   			jpmi_MainTable_CreateNewReminder.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_C,Event.CTRL_MASK) );
   			
   			jpmi_MainTable_ViewAllReminders = new JMenuItem();
   			jpmi_MainTable_ViewAllReminders.setText("View All Reminders");
   			jpmi_MainTable_ViewAllReminders.addActionListener( this );
   			jpmi_MainTable_ViewAllReminders.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_V,Event.CTRL_MASK) );

   			popupMenuForTable.add( jpmi_MainTable_CreateNewReminder );
   			popupMenuForTable.add( jpmi_MainTable_ViewAllReminders );
   			
   		} 
   		return popupMenuForTable;		
   	}

	java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd"); // HH:mm:ss
	public void fetchData(String dateStr) {
//			System.out.println( dateStr );
			//ComponentUtil.initTable( tableList, ps_sql);
			CalendarDao cd = new CalendarDaoImpl();
			try {
				tableList.getModel().removeAllRows();
				DefaultTableModel dtm = tableList.getModel().getTableModel();
				List<AwokeBean> list = cd.getScheduleList( dateStr );
				Vector<Object> v_rowData = null;
				String endOfToday = dateStr+" 23:59:59";
				Boolean isFuture = dateStr.compareTo(sdf.format(Calendar.getInstance().getTime()))>0;
				for (AwokeBean bean : list) {
					v_rowData = new Vector<Object>();
					v_rowData.add(""); //空白
					v_rowData.add(bean.getId());
					if( isFuture || endOfToday.compareTo(bean.getNextTime()) > 0 ){
						v_rowData.add(bean.getTitle());
					}else{
						v_rowData.add("<html><font color='gray'>[已完成]"+bean.getTitle()+"</font></html>");
					}
					dtm.addRow(v_rowData);
				}
				
			} catch (Exception e1) {
				e1.printStackTrace();
			}
	}


	/////////////////////////////////////////////////////////
       private JLabel datas[][]=new JLabel[6][7];//显示一月的日期
       private JLabel temp_label=null;
       private  JLabel label=null;
       private JPanel panel_Header,panel_Week,panel_Calendar;
       private Calendar calendar=null;
       private  JComboBox  year_box = null ;
       private  JComboBox month_box = null ;
       private int today ;
       private JRadioButton cross=null,system=null,motif=null;
       private ButtonGroup feel_group=null;
       private JButton show_help =null;
       
       
	@Override
	public void update(Observable o, Object arg) { 
		
		ResourceBundle bundle = I18nUtils.getBundle(DirectorConstants.I18n_Language_Name);

		this.getPopupMenuForTable();
		//I18nUtil.getBundleString(bundle, MainFrame.class, "tab.reminderMainPanel.Text")
		jpmi_MainTable_CreateNewReminder.setText(I18nUtil.getBundleString(bundle, CalendarSelectorPanel.class, "jpmi_MainTable_CreateNewReminder.Text"));
		jpmi_MainTable_ViewAllReminders.setText(I18nUtil.getBundleString(bundle, CalendarSelectorPanel.class, "jpmi_MainTable_ViewAllReminders.Text"));
		 
	}

	//wzw:改为Combox模式增加的方法
	public void addDateChangeListener(ChangeListener changeListener) {
		// TODO Auto-generated method stub
		
	}

	//wzw:改为Combox模式增加的方法
	public void setSelectedDate(Date selectionDate) {
		// TODO Auto-generated method stub
		
	}
        
}
